package com.itheima.app.controller.cmsController;

import com.itheima.commons.R;
import com.itheima.domain.db.cms.CmsSubject;
import com.itheima.service.cmsService.CmsSubjectService;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品专题
 * @author yin
 * @date 2022/10/12 11:09
 */
@RestController
public class CmsSubjectController {

    @DubboReference
    private CmsSubjectService cmsSubjectService;

    @GetMapping("/subject/listAll")
    public R findSubjectList() {
        List<CmsSubject> subjectList = cmsSubjectService.findSubjectList();
        return R.ok(subjectList);
    }


    @GetMapping("/subject/list")
    public R findSubjectByPageAndCondition(
            @RequestParam(required = false) String keyword,
            @RequestParam(defaultValue = "1", required = false) Integer pageNum,
            @RequestParam(defaultValue = "10", required = false) Integer pageSize) {
        PageBeanVo pageBeanVo = cmsSubjectService.findSubjectByPage(keyword,pageNum,pageSize);
        return  R.ok(pageBeanVo);
    }
}